<?php

class Zend_View_Helper_GetCaseInfo{
	
	
	public function getCaseInfo($caseitemid,$sendto,&$subject,$appendMsgEn='',$appendMsgCn=''){
		
		$message='';
		
		if($caseitemid!=''){
		
			$item=new CItem();
		
			$itemArray=$item->getDetail($caseitemid,'court_case');
			
			$member=new CMember();
    	
	    	$userArray=$member->getUserDetails(array('uid'=>$itemArray[0]['defendant_uid']));
	    	
	    	$defendant_username=$userArray[0]['username'];    	
	    	
	    	$userArray=$member->getUserDetails(array('uid'=>$itemArray[0]['uid']));
	    	
	    	$complainant_username=$userArray[0]['username'];
	    	
	    	if(strstr($sendto,'@')){
	    		
	    		$message='<div style="border:1px #cccccc solid;padding:10px;line-height:25px;">';
		
				$message.='<div>Case time: '.date('Y-m-d H:i:s',$itemArray[0]['add_time']).'</div>';
			
				$message.='<div>Case name: '.$itemArray[0]['subject'].'</div>';
				
				$message.='<div>Judge time: (Beijing time)'.date('Y-m-d H:i:s',$itemArray[0]['judge_time']).'</div>';
			
				$message.='<div>Complainant name: '.$complainant_username.'</div>';
				
				$message.='<div>Defendant name: '.$defendant_username.'</div>';
				
				$message.='<div>Product url: <a target="_blank" href="'.$itemArray[0]['product_url'].'">'.$itemArray[0]['product_url'].'</a></div>';
				
				$message.=$appendMsgEn;
				
				$message.='<div><a style="color:red" href="'.MY_URL.'/adminb?iframeUrl=adminb-court-more%3Fitemid%3D'.$caseitemid.'">Check it</a></div>';
			
				$message.='</div>';
				
				if($subject==''){
				
					$subject=$itemArray[0]['subject'].' case information';
					
				}
	    		
	    	}else{
		
				$message='<div style="border:1px #cccccc solid;padding:10px;line-height:25px;">';
			
				$message.='<div>案件时间: '.date('Y-m-d H:i:s',$itemArray[0]['add_time']).'</div>';
			
				$message.='<div>案件名称: '.$itemArray[0]['subject'].'</div>';
				
				$message.='<div>判决时间: (北京时间)'.date('Y-m-d H:i:s',$itemArray[0]['judge_time']).'</div>';
				
				$message.='<div>原告名称: '.$complainant_username.'</div>';
				
				$message.='<div>被告名称: '.$defendant_username.'</div>';
				
				$message.='<div>产品地址: <a target="_blank" href="'.$itemArray[0]['product_url'].'">'.$itemArray[0]['product_url'].'</a></div>';
				
				$message.=$appendMsgCn;
				
				$message.='<div><a style="color:red" href="'.MY_URL.'/admins?iframeUrl=admins-court-more%3Fitemid%3D'.$caseitemid.'">查看案件</a></div>';
			
				$message.='</div>';
				
				if($subject==''){
				
					$subject=$itemArray[0]['subject'].' 案件信息';
				
				}
				
	    	}
		
		}
		
		return $message;
		
	}

}

